#!/usr/bin/env python3

# -*- coding: utf-8 -*-

"""
app.py 只负责访问入口相关的代码
"""

from flask import Flask, request
from flask import render_template
from flask import jsonify
# from flask_cors import *
from datetime import timedelta

app = Flask(__name__)
# CORS(app, resources=r'/*')

# app.config['JSON_AS_ASCII'] = False
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = timedelta(seconds=1)


@app.route("/", methods=["GET"])
def index():
    # return render_template('sldf.html')
    return render_template('index.html')


@app.route("/api/files", methods=["GET", "POST"])
def file_list():
    # path = "static/picture/cfs"
    path = request.form['path']
    from views import Directory
    return jsonify(Directory(path).ret_api())


if __name__ == '__main__':
    app.debug = True
    app.run()
